<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="主表id" prop="excelId">
        <el-input
          v-model="queryParams.excelId"
          placeholder="请输入主表id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="序号" prop="xvh">
        <el-input
          v-model="queryParams.xvh"
          placeholder="请输入序号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="直径" prop="zhij">
        <el-input
          v-model="queryParams.zhij"
          placeholder="请输入直径"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="高度1" prop="gaod1">
        <el-input
          v-model="queryParams.gaod1"
          placeholder="请输入高度1"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="高度2" prop="gaod2">
        <el-input
          v-model="queryParams.gaod2"
          placeholder="请输入高度2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="高度3" prop="gaod3">
        <el-input
          v-model="queryParams.gaod3"
          placeholder="请输入高度3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="高度4" prop="gaod4">
        <el-input
          v-model="queryParams.gaod4"
          placeholder="请输入高度4"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="高度平均值" prop="gaodpjz">
        <el-input
          v-model="queryParams.gaodpjz"
          placeholder="请输入高度平均值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="体积" prop="tij">
        <el-input
          v-model="queryParams.tij"
          placeholder="请输入体积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="干燥试件空中质量" prop="ganzsjkzzl">
        <el-input
          v-model="queryParams.ganzsjkzzl"
          placeholder="请输入干燥试件空中质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="试件水中质量" prop="shijszzl">
        <el-input
          v-model="queryParams.shijszzl"
          placeholder="请输入试件水中质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="试件表干质量" prop="shijbgzl">
        <el-input
          v-model="queryParams.shijbgzl"
          placeholder="请输入试件表干质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="吸水率" prop="xisl">
        <el-input
          v-model="queryParams.xisl"
          placeholder="请输入吸水率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="毛体积相对密度" prop="maotjxdmd">
        <el-input
          v-model="queryParams.maotjxdmd"
          placeholder="请输入毛体积相对密度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="空隙率" prop="kongxl">
        <el-input
          v-model="queryParams.kongxl"
          placeholder="请输入空隙率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="有效沥青体积百分率" prop="youxlqtjbfl">
        <el-input
          v-model="queryParams.youxlqtjbfl"
          placeholder="请输入有效沥青体积百分率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="间隙率" prop="jianxl">
        <el-input
          v-model="queryParams.jianxl"
          placeholder="请输入间隙率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="沥青饱和度" prop="lqbhd">
        <el-input
          v-model="queryParams.lqbhd"
          placeholder="请输入沥青饱和度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="粗集料骨架间隙率" prop="cujlgjjxl">
        <el-input
          v-model="queryParams.cujlgjjxl"
          placeholder="请输入粗集料骨架间隙率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="稳定度" prop="wendd">
        <el-input
          v-model="queryParams.wendd"
          placeholder="请输入稳定度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="流值" prop="liuz">
        <el-input
          v-model="queryParams.liuz"
          placeholder="请输入流值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="马歇尔模数" prop="maxems">
        <el-input
          v-model="queryParams.maxems"
          placeholder="请输入马歇尔模数"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['report_lqhhl:lqhhlMxebgfjlbBsDetail2:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['report_lqhhl:lqhhlMxebgfjlbBsDetail2:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['report_lqhhl:lqhhlMxebgfjlbBsDetail2:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['report_lqhhl:lqhhlMxebgfjlbBsDetail2:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="lqhhlMxebgfjlbBsDetail2List" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="" align="center" prop="id" v-if="true"/>
      <el-table-column label="主表id" align="center" prop="excelId" />
      <el-table-column label="序号" align="center" prop="xvh" />
      <el-table-column label="直径" align="center" prop="zhij" />
      <el-table-column label="高度1" align="center" prop="gaod1" />
      <el-table-column label="高度2" align="center" prop="gaod2" />
      <el-table-column label="高度3" align="center" prop="gaod3" />
      <el-table-column label="高度4" align="center" prop="gaod4" />
      <el-table-column label="高度平均值" align="center" prop="gaodpjz" />
      <el-table-column label="体积" align="center" prop="tij" />
      <el-table-column label="干燥试件空中质量" align="center" prop="ganzsjkzzl" />
      <el-table-column label="试件水中质量" align="center" prop="shijszzl" />
      <el-table-column label="试件表干质量" align="center" prop="shijbgzl" />
      <el-table-column label="吸水率" align="center" prop="xisl" />
      <el-table-column label="毛体积相对密度" align="center" prop="maotjxdmd" />
      <el-table-column label="空隙率" align="center" prop="kongxl" />
      <el-table-column label="有效沥青体积百分率" align="center" prop="youxlqtjbfl" />
      <el-table-column label="间隙率" align="center" prop="jianxl" />
      <el-table-column label="沥青饱和度" align="center" prop="lqbhd" />
      <el-table-column label="粗集料骨架间隙率" align="center" prop="cujlgjjxl" />
      <el-table-column label="稳定度" align="center" prop="wendd" />
      <el-table-column label="流值" align="center" prop="liuz" />
      <el-table-column label="马歇尔模数" align="center" prop="maxems" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['report_lqhhl:lqhhlMxebgfjlbBsDetail2:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['report_lqhhl:lqhhlMxebgfjlbBsDetail2:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改沥青混合料马歇尔试验检测记录(干法)详情2对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="主表id" prop="excelId">
          <el-input v-model="form.excelId" placeholder="请输入主表id" />
        </el-form-item>
        <el-form-item label="序号" prop="xvh">
          <el-input v-model="form.xvh" placeholder="请输入序号" />
        </el-form-item>
        <el-form-item label="直径" prop="zhij">
          <el-input v-model="form.zhij" placeholder="请输入直径" />
        </el-form-item>
        <el-form-item label="高度1" prop="gaod1">
          <el-input v-model="form.gaod1" placeholder="请输入高度1" />
        </el-form-item>
        <el-form-item label="高度2" prop="gaod2">
          <el-input v-model="form.gaod2" placeholder="请输入高度2" />
        </el-form-item>
        <el-form-item label="高度3" prop="gaod3">
          <el-input v-model="form.gaod3" placeholder="请输入高度3" />
        </el-form-item>
        <el-form-item label="高度4" prop="gaod4">
          <el-input v-model="form.gaod4" placeholder="请输入高度4" />
        </el-form-item>
        <el-form-item label="高度平均值" prop="gaodpjz">
          <el-input v-model="form.gaodpjz" placeholder="请输入高度平均值" />
        </el-form-item>
        <el-form-item label="体积" prop="tij">
          <el-input v-model="form.tij" placeholder="请输入体积" />
        </el-form-item>
        <el-form-item label="干燥试件空中质量" prop="ganzsjkzzl">
          <el-input v-model="form.ganzsjkzzl" placeholder="请输入干燥试件空中质量" />
        </el-form-item>
        <el-form-item label="试件水中质量" prop="shijszzl">
          <el-input v-model="form.shijszzl" placeholder="请输入试件水中质量" />
        </el-form-item>
        <el-form-item label="试件表干质量" prop="shijbgzl">
          <el-input v-model="form.shijbgzl" placeholder="请输入试件表干质量" />
        </el-form-item>
        <el-form-item label="吸水率" prop="xisl">
          <el-input v-model="form.xisl" placeholder="请输入吸水率" />
        </el-form-item>
        <el-form-item label="毛体积相对密度" prop="maotjxdmd">
          <el-input v-model="form.maotjxdmd" placeholder="请输入毛体积相对密度" />
        </el-form-item>
        <el-form-item label="空隙率" prop="kongxl">
          <el-input v-model="form.kongxl" placeholder="请输入空隙率" />
        </el-form-item>
        <el-form-item label="有效沥青体积百分率" prop="youxlqtjbfl">
          <el-input v-model="form.youxlqtjbfl" placeholder="请输入有效沥青体积百分率" />
        </el-form-item>
        <el-form-item label="间隙率" prop="jianxl">
          <el-input v-model="form.jianxl" placeholder="请输入间隙率" />
        </el-form-item>
        <el-form-item label="沥青饱和度" prop="lqbhd">
          <el-input v-model="form.lqbhd" placeholder="请输入沥青饱和度" />
        </el-form-item>
        <el-form-item label="粗集料骨架间隙率" prop="cujlgjjxl">
          <el-input v-model="form.cujlgjjxl" placeholder="请输入粗集料骨架间隙率" />
        </el-form-item>
        <el-form-item label="稳定度" prop="wendd">
          <el-input v-model="form.wendd" placeholder="请输入稳定度" />
        </el-form-item>
        <el-form-item label="流值" prop="liuz">
          <el-input v-model="form.liuz" placeholder="请输入流值" />
        </el-form-item>
        <el-form-item label="马歇尔模数" prop="maxems">
          <el-input v-model="form.maxems" placeholder="请输入马歇尔模数" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listLqhhlMxebgfjlbBsDetail2, getLqhhlMxebgfjlbBsDetail2, delLqhhlMxebgfjlbBsDetail2, addLqhhlMxebgfjlbBsDetail2, updateLqhhlMxebgfjlbBsDetail2 } from "@/api/report_lqhhl/lqhhlMxebgfjlbBsDetail2";

export default {
  name: "LqhhlMxebgfjlbBsDetail2",
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 沥青混合料马歇尔试验检测记录(干法)详情2表格数据
      lqhhlMxebgfjlbBsDetail2List: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        excelId: undefined,
        xvh: undefined,
        zhij: undefined,
        gaod1: undefined,
        gaod2: undefined,
        gaod3: undefined,
        gaod4: undefined,
        gaodpjz: undefined,
        tij: undefined,
        ganzsjkzzl: undefined,
        shijszzl: undefined,
        shijbgzl: undefined,
        xisl: undefined,
        maotjxdmd: undefined,
        kongxl: undefined,
        youxlqtjbfl: undefined,
        jianxl: undefined,
        lqbhd: undefined,
        cujlgjjxl: undefined,
        wendd: undefined,
        liuz: undefined,
        maxems: undefined,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [
          { required: true, message: "不能为空", trigger: "blur" }
        ],
        excelId: [
          { required: true, message: "主表id不能为空", trigger: "blur" }
        ],
        xvh: [
          { required: true, message: "序号不能为空", trigger: "blur" }
        ],
        zhij: [
          { required: true, message: "直径不能为空", trigger: "blur" }
        ],
        gaod1: [
          { required: true, message: "高度1不能为空", trigger: "blur" }
        ],
        gaod2: [
          { required: true, message: "高度2不能为空", trigger: "blur" }
        ],
        gaod3: [
          { required: true, message: "高度3不能为空", trigger: "blur" }
        ],
        gaod4: [
          { required: true, message: "高度4不能为空", trigger: "blur" }
        ],
        gaodpjz: [
          { required: true, message: "高度平均值不能为空", trigger: "blur" }
        ],
        tij: [
          { required: true, message: "体积不能为空", trigger: "blur" }
        ],
        ganzsjkzzl: [
          { required: true, message: "干燥试件空中质量不能为空", trigger: "blur" }
        ],
        shijszzl: [
          { required: true, message: "试件水中质量不能为空", trigger: "blur" }
        ],
        shijbgzl: [
          { required: true, message: "试件表干质量不能为空", trigger: "blur" }
        ],
        xisl: [
          { required: true, message: "吸水率不能为空", trigger: "blur" }
        ],
        maotjxdmd: [
          { required: true, message: "毛体积相对密度不能为空", trigger: "blur" }
        ],
        kongxl: [
          { required: true, message: "空隙率不能为空", trigger: "blur" }
        ],
        youxlqtjbfl: [
          { required: true, message: "有效沥青体积百分率不能为空", trigger: "blur" }
        ],
        jianxl: [
          { required: true, message: "间隙率不能为空", trigger: "blur" }
        ],
        lqbhd: [
          { required: true, message: "沥青饱和度不能为空", trigger: "blur" }
        ],
        cujlgjjxl: [
          { required: true, message: "粗集料骨架间隙率不能为空", trigger: "blur" }
        ],
        wendd: [
          { required: true, message: "稳定度不能为空", trigger: "blur" }
        ],
        liuz: [
          { required: true, message: "流值不能为空", trigger: "blur" }
        ],
        maxems: [
          { required: true, message: "马歇尔模数不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询沥青混合料马歇尔试验检测记录(干法)详情2列表 */
    getList() {
      this.loading = true;
      listLqhhlMxebgfjlbBsDetail2(this.queryParams).then(response => {
        this.lqhhlMxebgfjlbBsDetail2List = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        excelId: undefined,
        xvh: undefined,
        zhij: undefined,
        gaod1: undefined,
        gaod2: undefined,
        gaod3: undefined,
        gaod4: undefined,
        gaodpjz: undefined,
        tij: undefined,
        ganzsjkzzl: undefined,
        shijszzl: undefined,
        shijbgzl: undefined,
        xisl: undefined,
        maotjxdmd: undefined,
        kongxl: undefined,
        youxlqtjbfl: undefined,
        jianxl: undefined,
        lqbhd: undefined,
        cujlgjjxl: undefined,
        wendd: undefined,
        liuz: undefined,
        maxems: undefined,
        delFlag: undefined,
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加沥青混合料马歇尔试验检测记录(干法)详情2";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row.id || this.ids
      getLqhhlMxebgfjlbBsDetail2(id).then(response => {
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = "修改沥青混合料马歇尔试验检测记录(干法)详情2";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.id != null) {
            updateLqhhlMxebgfjlbBsDetail2(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          } else {
            addLqhhlMxebgfjlbBsDetail2(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除沥青混合料马歇尔试验检测记录(干法)详情2编号为"' + ids + '"的数据项？').then(() => {
        this.loading = true;
        return delLqhhlMxebgfjlbBsDetail2(ids);
      }).then(() => {
        this.loading = false;
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('report_lqhhl/lqhhlMxebgfjlbBsDetail2/export', {
        ...this.queryParams
      }, `lqhhlMxebgfjlbBsDetail2_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
